package com.mall.xiaomi.mapper;

import com.mall.xiaomi.pojo.Collect;
import com.mall.xiaomi.pojo.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author zhanggaoxiang
 * @ClassName CollectMapper
 * @Description TODO
 * @Date 2021/2/25 14:45
 * @Version 1.0
 **/
public interface CollectMapper {

    @Select("select p.* from product as p,collect as c where c.user_id=#{userId} and c.product_id=p.product_id")
    List<Product> getCollectByUid(Integer userId);

    @Delete("delete from collect where user_id=#{userId} and product_id=#{productId}")
    int delCollectById(Collect collect);

    @Select("select * from collect where user_id=#{userId} and product_id=#{productId}")
    Collect findCollectById(Collect collect);

    @Insert("insert into collect(user_id,product_id,collect_time) values (#{userId},#{productId},#{collectTime})")
    int addCollect(Collect collect);
}
